package com.qf.medicaldoctoradmin.healthRecord.controller;

import com.qf.common.annotation.NoLoginCheck;
import com.qf.common.common.R;
import com.qf.common.entity.User;
import com.qf.medicaldoctoradmin.healthRecord.service.HealthService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * (User)表控制层
 *
 * @author makejava
 * @since 2024-11-09 11:14:13
 */
@Api(tags = "健康档案基础信息")
@RestController
@RequestMapping("/user")
@CrossOrigin
public class HealthController {

    @Resource
    private HealthService healthService;

    /**
     * 修改数据
     *
     * @param user 实体对象
     * @return 修改结果
     */
    @ApiOperation(value = "修改健康档案基础信息", notes = "修改健康档案的基本信息")
    @NoLoginCheck
    @PostMapping("/update")
    public R update(@RequestBody User user) {
        healthService.update(user);
        return R.ok("保存成功!");
    }

    /**
     * 上传头像
     * @param
     * @return
     */
    @ApiOperation(value = "基础信息上传头像", notes = "给健康档案的基础信息上传或更换头像")
    @NoLoginCheck
    @PostMapping("/upload/avatar")
    public R uploadAvatar(MultipartFile file) {
        String path = healthService.uploadAvatar(file);
        return R.ok(path);
    }


}

